import {createApp, reactive} from "vue";
import MyLoading from './MyLoading.vue'

const loadingConfig = reactive({
  title: "加载中...",
  show: false
})

const $loading = createApp(MyLoading, {loadingConfig}).mount(document.createElement("app"))
const loadingController = {
  show(title: string) { // 控制显示loading的方法
    loadingConfig.show = true
    loadingConfig.title = title
    document.body.appendChild($loading.$el)
  },

  hide() { // 控制loading隐藏的方法
    loadingConfig.show = false
  }
}

export default {
  install(app: any) {
    // console.log(app);
    // Vue.prototype.$http = axios
    app.config.globalProperties.$loadingController = loadingController
  }
}
